import axios from 'axios'
import router from '@/router'
import { Toast } from 'vant';
axios.defaults.baseURL = 'http://120.53.31.103:84/'

axios.interceptors.request.use(function(config) {
    Toast.loading({
        message: '加载中...',
        forbidClick: true,
        loadingType:'spinner'
    });
    config.headers.Authorization='Bearer'+localStorage.getItem('LoginToken')
    
    return config
}, function(error) {
    return Promise.reject(error)
})
axios.interceptors.response.use(function(response) {
    Toast.clear()
    if (response.data.code == 400) {
        router.push('/login')
    }
    return response.data
}, function(error) {
    return Promise.reject(error)
})
export default axios